class CritObject(object):
    def __init__(self, *args, **kwargs):
        self.__properties = {'id':0,'label':'','dim':3, 'crd':None}
        cp = kwargs.pop("object", None)
        if( cp ):

            try:
                import copy
                self.__properties = copy.deepcopy(cp._getPropertiesDict())
            except:
                pass
            
    def _getPropertiesDict(self):
        return self.__properties  
    def __str__(self):
        strs = ''
        keys = self.__properties.keys()
        for key in keys:
            strs += "%s: %s; "%(key,self.__properties[key])
        #strs += "wc: %s"%self.__worldCoordinates.__str__()
        return strs
    def getID(self):
        return self.getProperty("id")
    def setID(self,id):
        self.setProperty("id",id)
    def getLabel(self):
        return self.getProperty("label")
    def setLabel(self,label):
        self.setProperty("label",label)
    def setProperty(self, property, value):
        """set the property with value"""
        self.__properties[property] = value
    def getProperty(self, property):
        return self.__properties.get(property)
    
    def map(self,m):
        """map the critical object p based on the transform matrix m"""
        crds = self.__properties["crd"]
        self.__properties["mcrd"] = crds*m
    def __getitem__(self,key):
        crds = self.__properties["crd"]
        return crds[key]
class CritObjectDraw(CritObject):
    def __init__(self, color='Red'):
        super(CritObjectDraw,self).__init__()
        self.__color = color
    def __str__(self):
        strs = super(CritObjectDraw,self).__str__()
        strs += "color: %s"%(self.__color)
        return strs
    def getColor(self):
        return self.__color
    def setColor(self,color):
        self.__color = color
        
